// 导入 mongoose
const mongoose = require('mongoose')

// 创建文档的结构对象
// 设置集合中文档的属性以及属性值的类型
const RoutersSchema = new mongoose.Schema({
  name: { type: String, required: true },
  path: { type: String, required: true },
  title: { type: String, required: true },
  requiresAuth: { type: Boolean, required: true },
  icon: { type: String, required: true },
  menuType: { type: String, required: true },
  pinTab: { type: Boolean, default: false },
  keepAlive: { type: Boolean, default: false },
  componentPath: { type: String },
  id: { type: Number, required: true },
  pid: { type: Number, default: null }
})
// 创建模型对象
// 模型对象是对文档操作的封装对象
const RoutersModel = mongoose.model('router', RoutersSchema)

// 暴露模型对象
module.exports = RoutersModel
